/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
 * Copyright 2022 RackTop Systems, Inc.
 */
#ifndef _SMB_WINIOCTL_H
#define	_SMB_WINIOCTL_H

/*
 * Standard Windows NT IOCTL/FSCTL definitions (derived from the VC++
 * include file of the same name).
 */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _DEVIOCTL_
#define	_DEVIOCTL_

/*
 * begin_ntddk begin_wdm begin_nthal begin_ntifs
 *
 * Define the various device type values.  Note that values used by Microsoft
 * Corporation are in the range 0-32767, and 32768-65535 are reserved for use
 * by customers.
 */

#define	DEVICE_TYPE DWORD

#define	FILE_DEVICE_BEEP		0x00000001
#define	FILE_DEVICE_CD_ROM		0x00000002
#define	FILE_DEVICE_CD_ROM_FILE_SYSTEM	0x00000003
#define	FILE_DEVICE_CONTROLLER		0x00000004
#define	FILE_DEVICE_DATALINK		0x00000005
#define	FILE_DEVICE_DFS			0x00000006
#define	FILE_DEVICE_DISK		0x00000007
#define	FILE_DEVICE_DISK_FILE_SYSTEM	0x00000008
#define	FILE_DEVICE_FILE_SYSTEM		0x00000009
#define	FILE_DEVICE_INPORT_PORT		0x0000000a
#define	FILE_DEVICE_KEYBOARD		0x0000000b
#define	FILE_DEVICE_MAILSLOT		0x0000000c
#define	FILE_DEVICE_MIDI_IN		0x0000000d
#define	FILE_DEVICE_MIDI_OUT		0x0000000e
#define	FILE_DEVICE_MOUSE		0x0000000f
#define	FILE_DEVICE_MULTI_UNC_PROVIDER	0x00000010
#define	FILE_DEVICE_NAMED_PIPE		0x00000011
#define	FILE_DEVICE_NETWORK		0x00000012
#define	FILE_DEVICE_NETWORK_BROWSER	0x00000013
#define	FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
#define	FILE_DEVICE_NULL		0x00000015
#define	FILE_DEVICE_PARALLEL_PORT	0x00000016
#define	FILE_DEVICE_PHYSICAL_NETCARD	0x00000017
#define	FILE_DEVICE_PRINTER		0x00000018
#define	FILE_DEVICE_SCANNER		0x00000019
#define	FILE_DEVICE_SERIAL_MOUSE_PORT	0x0000001a
#define	FILE_DEVICE_SERIAL_PORT		0x0000001b
#define	FILE_DEVICE_SCREEN		0x0000001c
#define	FILE_DEVICE_SOUND		0x0000001d
#define	FILE_DEVICE_STREAMS		0x0000001e
#define	FILE_DEVICE_TAPE		0x0000001f
#define	FILE_DEVICE_TAPE_FILE_SYSTEM	0x00000020
#define	FILE_DEVICE_TRANSPORT		0x00000021
#define	FILE_DEVICE_UNKNOWN		0x00000022
#define	FILE_DEVICE_VIDEO		0x00000023
#define	FILE_DEVICE_VIRTUAL_DISK	0x00000024
#define	FILE_DEVICE_WAVE_IN		0x00000025
#define	FILE_DEVICE_WAVE_OUT		0x00000026
#define	FILE_DEVICE_8042_PORT		0x00000027
#define	FILE_DEVICE_NETWORK_REDIRECTOR	0x00000028
#define	FILE_DEVICE_BATTERY		0x00000029
#define	FILE_DEVICE_BUS_EXTENDER	0x0000002a
#define	FILE_DEVICE_MODEM		0x0000002b
#define	FILE_DEVICE_VDM			0x0000002c
#define	FILE_DEVICE_MASS_STORAGE	0x0000002d
#define	FILE_DEVICE_SMB			0x0000002e
#define	FILE_DEVICE_KS			0x0000002f
#define	FILE_DEVICE_CHANGER		0x00000030
#define	FILE_DEVICE_SMARTCARD		0x00000031
#define	FILE_DEVICE_ACPI		0x00000032
#define	FILE_DEVICE_DVD			0x00000033
#define	FILE_DEVICE_FULLSCREEN_VIDEO	0x00000034
#define	FILE_DEVICE_DFS_FILE_SYSTEM	0x00000035
#define	FILE_DEVICE_DFS_VOLUME		0x00000036

/*
 * Macro definition for defining IOCTL and FSCTL function control codes.  Note
 * that function codes 0-2047 are reserved for Microsoft Corporation, and
 * 2048-4095 are reserved for customers.
 */

#define	CTL_CODE(DeviceType, Function, Method, Access) \
	(((DeviceType) << 16) | ((Access) << 14) |     \
	((Function) << 2) | (Method))

/*
 * Define the method codes for how buffers are passed for I/O and FS controls
 */

#define	METHOD_BUFFERED			0
#define	METHOD_IN_DIRECT		1
#define	METHOD_OUT_DIRECT		2
#define	METHOD_NEITHER			3

/*
 * Define the access check value for any access
 */

#define	FILE_ANY_ACCESS			0
#define	FILE_READ_ACCESS		0x0001	/* file & pipe */
#define	FILE_WRITE_ACCESS		0x0002	/* file & pipe */

/* end_ntddk end_wdm end_nthal end_ntifs */

#endif /* _DEVIOCTL_ */


#ifndef _NTDDSTOR_H_
#define	_NTDDSTOR_H_

#ifdef __cplusplus
extern "C" {
#endif

/*
 * IoControlCode values for storage devices
 */

#define	IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE

/*
 * The following device control codes are common for all class drivers.  They
 * should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
 * common codes
 */

#define	IOCTL_STORAGE_CHECK_VERIFY \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_MEDIA_REMOVAL \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_EJECT_MEDIA \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_LOAD_MEDIA \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_RESERVE \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_RELEASE \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_FIND_NEW_DEVICES \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)

#define	IOCTL_STORAGE_GET_MEDIA_TYPES \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_STORAGE_GET_MEDIA_TYPES_EX \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define	IOCTL_STORAGE_RESET_BUS \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_STORAGE_RESET_DEVICE \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)

#define	IOCTL_STORAGE_GET_DEVICE_NUMBER \
	CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)


#ifdef __cplusplus
}
#endif
#endif /* _NTDDSTOR_H_ */

/*
 * IoControlCode values for disk devices.
 */

#define	IOCTL_DISK_BASE			FILE_DEVICE_DISK
#define	IOCTL_DISK_GET_DRIVE_GEOMETRY \
	CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_GET_PARTITION_INFO \
	CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_SET_PARTITION_INFO \
	CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_DISK_GET_DRIVE_LAYOUT \
	CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_SET_DRIVE_LAYOUT \
	CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_DISK_VERIFY \
	CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_FORMAT_TRACKS \
	CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED,	\
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_DISK_REASSIGN_BLOCKS \
	CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_DISK_PERFORMANCE \
	CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_IS_WRITABLE \
	CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_LOGGING \
	CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_FORMAT_TRACKS_EX \
	CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_DISK_HISTOGRAM_STRUCTURE \
	CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_HISTOGRAM_DATA \
	CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_HISTOGRAM_RESET \
	CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_REQUEST_STRUCTURE \
	CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_REQUEST_DATA \
	CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	IOCTL_DISK_CONTROLLER_NUMBER \
	CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)

/*
 * IOCTL support for SMART drive fault prediction.
 */

#define	SMART_GET_VERSION \
	CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	SMART_SEND_DRIVE_COMMAND \
	CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED,	\
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	SMART_RCV_DRIVE_DATA \
	CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)


/*
 * The following device control codes are common for all class drivers.  The
 * functions codes defined here must match all of the other class drivers.
 *
 * Warning: these codes will be replaced in the future by equivalent
 * IOCTL_STORAGE codes
 */

#define	IOCTL_DISK_CHECK_VERIFY \
	CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_MEDIA_REMOVAL \
	CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_EJECT_MEDIA \
	CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_LOAD_MEDIA \
	CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_RESERVE \
	CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_RELEASE \
	CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_FIND_NEW_DEVICES \
	CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_DISK_GET_MEDIA_TYPES \
	CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define	IOCTL_CHANGER_BASE		FILE_DEVICE_CHANGER

#define	IOCTL_CHANGER_GET_PARAMETERS \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_GET_STATUS \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_GET_PRODUCT_DATA \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_SET_ACCESS \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_CHANGER_GET_ELEMENT_STATUS \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_SET_POSITION \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_EXCHANGE_MEDIUM \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_MOVE_MEDIUM \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_REINITIALIZE_TRANSPORT \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	IOCTL_CHANGER_QUERY_VOLUME_TAGS \
	CTL_CODE(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)

#ifndef _FILESYSTEMFSCTL_
#define	_FILESYSTEMFSCTL_
/*
 * The following is a list of the native file system fsctls followed by
 * additional network file system fsctls, DFS fsctls and Named Pipe fsctls.
 * Some values have been decommissioned.
 */

/* FILE_DEVICE_FILE_SYSTEM */
#define	FSCTL_REQUEST_OPLOCK_LEVEL_1 \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  0, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_REQUEST_OPLOCK_LEVEL_2 \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  1, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_REQUEST_BATCH_OPLOCK \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  2, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_OPLOCK_BREAK_ACKNOWLEDGE \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  3, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_OPBATCH_ACK_CLOSE_PENDING \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  4, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_OPLOCK_BREAK_NOTIFY \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  5, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_LOCK_VOLUME \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  6, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_UNLOCK_VOLUME \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_DISMOUNT_VOLUME \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* decommissioned fsctl value 9 */
#define	FSCTL_IS_VOLUME_MOUNTED \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* PATHNAME_BUFFER, */
#define	FSCTL_IS_PATHNAME_VALID \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_MARK_VOLUME_DIRTY \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* decommissioned fsctl value 13 */
#define	FSCTL_QUERY_RETRIEVAL_POINTERS \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14,  METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_GET_COMPRESSION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_SET_COMPRESSION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
/* decommissioned fsctl value 17 */
/* decommissioned fsctl value 18 */
#define	FSCTL_MARK_AS_SYSTEM_HIVE \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19,  METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_OPLOCK_BREAK_ACK_NO_2 \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_INVALIDATE_VOLUMES \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* FSCTL_QUERY_FAT_BPB_BUFFER */
#define	FSCTL_QUERY_FAT_BPB \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_REQUEST_FILTER_OPLOCK \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* FILESYSTEM_STATISTICS */
#define	FSCTL_FILESYSTEM_GET_STATISTICS \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* NTFS_VOLUME_DATA_BUFFER */
#define	FSCTL_GET_NTFS_VOLUME_DATA \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* NTFS_FILE_RECORD_INPUT_BUFFER, NTFS_FILE_RECORD_OUTPUT_BUFFER */
#define	FSCTL_GET_NTFS_FILE_RECORD \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* STARTING_LCN_INPUT_BUFFER, VOLUME_BITMAP_BUFFER */
#define	FSCTL_GET_VOLUME_BITMAP \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER */
#define	FSCTL_GET_RETRIEVAL_POINTERS \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* MOVE_FILE_DATA, */
#define	FSCTL_MOVE_FILE \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_IS_VOLUME_DIRTY \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_GET_HFS_INFORMATION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 31, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_ALLOW_EXTENDED_DASD_IO \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER,  FILE_ANY_ACCESS)
#define	FSCTL_READ_PROPERTY_DATA \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 33, METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_WRITE_PROPERTY_DATA \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 34, METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_FIND_FILES_BY_SID \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS)
/* decommissioned fsctl value 36 */
#define	FSCTL_DUMP_PROPERTY_DATA \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 37,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* FILE_OBJECTID_BUFFER */
#define	FSCTL_SET_OBJECT_ID \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* FILE_OBJECTID_BUFFER */
#define	FSCTL_GET_OBJECT_ID \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_DELETE_OBJECT_ID \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* REPARSE_DATA_BUFFER, */
#define	FSCTL_SET_REPARSE_POINT \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* REPARSE_DATA_BUFFER */
#define	FSCTL_GET_REPARSE_POINT \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* REPARSE_DATA_BUFFER, */
#define	FSCTL_DELETE_REPARSE_POINT \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* MFT_ENUM_DATA, */
#define	FSCTL_ENUM_USN_DATA \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44,  METHOD_NEITHER, FILE_READ_ACCESS)
/* BULK_SECURITY_TEST_DATA, */
#define	FSCTL_SECURITY_ID_CHECK \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45,  METHOD_NEITHER, FILE_READ_ACCESS)
/* READ_USN_JOURNAL_DATA, USN */
#define	FSCTL_READ_USN_JOURNAL \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46,  METHOD_NEITHER, FILE_READ_ACCESS)
#define	FSCTL_SET_OBJECT_ID_EXTENDED \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* FILE_OBJECTID_BUFFER */
#define	FSCTL_CREATE_OR_GET_OBJECT_ID \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_SET_SPARSE \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* FILE_ZERO_DATA_INFORMATION, */
#define	FSCTL_SET_ZERO_DATA \
    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_ACCESS)
/* FILE_ALLOCATED_RANGE_BUFFER, FILE_ALLOCATED_RANGE_BUFFER */
#define	FSCTL_QUERY_ALLOCATED_RANGES \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51,  METHOD_NEITHER, FILE_READ_ACCESS)
#define	FSCTL_ENABLE_UPGRADE \
    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_ACCESS)
/* ENCRYPTION_BUFFER, */
#define	FSCTL_SET_ENCRYPTION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_ENCRYPTION_FSCTL_IO \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* ENCRYPTED_DATA_INFO, */
#define	FSCTL_WRITE_RAW_ENCRYPTED \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* REQUEST_RAW_ENCRYPTED_DATA, ENCRYPTED_DATA_INFO */
#define	FSCTL_READ_RAW_ENCRYPTED \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* CREATE_USN_JOUNRAL_DATA, */
#define	FSCTL_CREATE_USN_JOURNAL \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57,  METHOD_NEITHER, FILE_READ_ACCESS)
/* Read the Usn Record for a file */
#define	FSCTL_READ_FILE_USN_DATA \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58,  METHOD_NEITHER, FILE_ANY_ACCESS)
/* Generate Close Usn Record */
#define	FSCTL_WRITE_USN_CLOSE_RECORD \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59,  METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_EXTEND_VOLUME \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_SIS_COPYFILE \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_RECALL_FILE \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
#define	FSCTL_SET_DEFECT_MANAGEMENT \
    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define	FSCTL_QUERY_SPARING_INFO \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_QUERY_ON_DISK_VOLUME_INFO \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_SET_ZERO_ON_DEALLOCATION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_SET_SHORT_NAME_BEHAVIOR \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_FILE_LEVEL_TRIM \
    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define	FSCTL_OFFLOAD_READ \
    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	FSCTL_OFFLOAD_WRITE \
    CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define	FSCTL_GET_INTEGRITY_INFORMATION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_SET_INTEGRITY_INFORMATION \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, \
		FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	FSCTL_QUERY_FILE_REGIONS \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define	FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT \
	CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 272, METHOD_BUFFERED, FILE_ANY_ACCESS)

/* FILE_DEVICE_NETWORK_FILE_SYSTEM */
/* Read the snapshot info for Volume Shadow Copy Services */
#define	FSCTL_SRV_ENUMERATE_SNAPSHOTS \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x19, \
	METHOD_BUFFERED, FILE_READ_ACCESS)
/* Retrieve an opaque file reference for server-side data movement */
#define	FSCTL_SRV_REQUEST_RESUME_KEY \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x1e, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_LMR_GET_LINK_TRACKING_INFORMATION \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x3a, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_LMR_SET_LINK_TRACKING_INFORMATION \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x3b, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)
/* server-side data movement */
#define	FSCTL_SRV_COPYCHUNK \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x3c, \
	METHOD_OUT_DIRECT, FILE_READ_ACCESS)
/* server-side data movement */
#define	FSCTL_SRV_COPYCHUNK_WRITE \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x3c, \
	METHOD_OUT_DIRECT, FILE_WRITE_ACCESS)
#define	FSCTL_SRV_NOTIFY_TRANSACTION \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x46, \
	METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define	FSCTL_SRV_READ_HASH \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x6e, \
	METHOD_NEITHER, FILE_READ_ACCESS)
#define	FSCTL_SRV_UNKNOWN_x71 \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x71, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_LMR_REQUEST_RESILIENCY \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x75, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_QUERY_NETWORK_INTERFACE_INFO \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x7f, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_VALIDATE_NEGOTIATE_INFO \
	CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 0x81, \
	METHOD_BUFFERED, FILE_ANY_ACCESS)

/* FILE_DEVICE_DFS */
#define	FSCTL_DFS_GET_REFERRALS \
	CTL_CODE(FILE_DEVICE_DFS, 0x65, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define	FSCTL_DFS_GET_REFERRALS_EX \
	CTL_CODE(FILE_DEVICE_DFS, 0x6c, METHOD_BUFFERED, FILE_ANY_ACCESS)

/* FILE_DEVICE_NAMED_PIPE */
#define	FSCTL_PIPE_PEEK \
	CTL_CODE(FILE_DEVICE_NAMED_PIPE, 3, METHOD_BUFFERED, FILE_READ_ACCESS)
#define	FSCTL_PIPE_TRANSCEIVE \
	CTL_CODE(FILE_DEVICE_NAMED_PIPE, 5, METHOD_NEITHER, \
	FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define	FSCTL_PIPE_WAIT \
	CTL_CODE(FILE_DEVICE_NAMED_PIPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)

#endif /* _FILESYSTEMFSCTL_ */

#ifdef __cplusplus
}
#endif

#endif /* _SMB_WINIOCTL_H */
